﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Ocmf.Types;

namespace Ocmf.Forms
{
    public partial class EditDelayForm : Form
    {
        public Delay Delay { get; set; }
        
        public EditDelayForm(Delay delay)
        {
            InitializeComponent();

            Delay = delay;

            if(delay.Duration == int.MaxValue)
            {
                durationRadioButton.Checked = true;
                nosePokeRadioButton.Checked = false;
            }
            else
            {
                durationNumericUpDown.Value = delay.Duration;
                durationRadioButton.Checked = true;
                nosePokeRadioButton.Checked = false;
            }
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            if (nosePokeRadioButton.Checked)
                Delay.Duration = int.MaxValue;
            else
                Delay.Duration = Decimal.ToInt32(durationNumericUpDown.Value);

            DialogResult = DialogResult.OK;
        }
    }
}
